package {
	import com.sociodox.theminer.TheMiner;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	import assets.AssetsAA;
	
	import org.agony2d.Agony;
	import org.agony2d.gpu.AgonyAA;
	import org.agony2d.gpu.core.WorldAA;
	import org.agony2d.input.KeyboardManager;
	import org.agony2d.input.TouchManager;
	import org.agony2d.notify.AEvent;
	
	import stateAAs.*;

	
	[SWF(width = "960", height = "600", frameRate = "30", backgroundColor = "0xFFFFFF")]
public class MobileGpuTest extends Sprite {
	
	public function MobileGpuTest() {
		super();
		
		
		
		Agony.startup(stage)
		KeyboardManager.getInstance().initialize()
		AgonyAA.startup(0xFFFFFF, false, 0)
		AgonyAA.addEventListener(AEvent.BEGINNING, onContextBeginning)
		AgonyAA.addEventListener(AEvent.RESET, onContextReset)
		//AgonyAA.enableErrorChecking = true
		
		
		stage.addChild(new Stats)
		addChild(new AssetsAA.img_flash_icon_64)
		
		TouchManager.getInstance().multiTouchEnabled = true
	}
	
	
	private var mWorld:WorldAA
	
	
	private function doAddTextures() : void{

		AgonyAA.addFullTexture("A_32", (new AssetsAA.img_flash_icon_32).bitmapData, false)
		AgonyAA.addFullTexture("A_64", (new AssetsAA.img_flash_icon_64).bitmapData, false)
		AgonyAA.addFullTexture("B", (new AssetsAA.img_role).bitmapData, false)
		AgonyAA.addFullTexture("bgA", (new AssetsAA.img_bg).bitmapData, false)
		AgonyAA.addFullTexture("bgB", (new AssetsAA.img_bg).bitmapData, false)
	}
	
	private function onContextBeginning(e:AEvent):void {
		AgonyAA.removeEventListener(AEvent.BEGINNING, onContextBeginning)
		trace('beginning...')
		this.doAddTextures()
		/////////////////////////////////////////////////////////////////
		/////////////////////////////////////////////////////////////////
		/////////////////////////////////////////////////////////////////
		
		//mWorld = AgonyAA.createWorld(-1, -1)
		//mWorld.x = 100
		//mWorld.createLayer(Image_StateAA).stateArgs = [1000]
		//mWorld.createLayer(Image_StateAA).stateArgs = [1000]
		//mWorld.createLayer(Image_StateAA).stateArgs = [1000]
		//mWorld.reset()
		
		mWorld = AgonyAA.createWorld(-1, -1)
		mWorld.createLayer(Benchmark_StateAA)
		//mWorld.createLayer(Batch_StateAA).stateArgs = [8000]
		//mWorld.createLayer(Fusion_StateAA)
		//mWorld.createLayer(Interact_StateAA)
		mWorld.reset()
		
		//mWorld = AgonyAA.createWorld(-1, -1)
		//mWorld.x = 50
		//mWorld.createLayer(BgAStateAA)
		//mWorld.createLayer(TintedImage_StateAA).stateArgs = [3000]
		//mWorld.createLayer(TintedImage_StateAA).stateArgs = [3000]
		//mWorld.createLayer(TintedImage_StateAA).stateArgs = [3000]
		//mWorld.createLayer(TintedImage_StateAA).stateArgs = [3000]
		//mWorld.reset()
		
		
		KeyboardManager.getInstance().getState().press.addEventListener("R", function(e:AEvent):void {
			mWorld.reset()
		})
	}
	
	private function onContextReset(e:AEvent):void{
		this.doAddTextures()
	}
	
}
}